package com.emcom.gotour.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.web.util.HtmlUtils;

import com.emcom.gotour.dao.TourCategoryDao;
import com.emcom.gotour.po.TourCategory;

public class TourCategoryServiceImpl implements TourCategoryService {

	private TourCategoryDao tourCategoryDao;

	public void delete(long id) {
		TourCategory parameters = new TourCategory();
		parameters.setId(id);
		tourCategoryDao.delete(parameters);
	}

	public void insert(String tourCategory) {
		TourCategory parameters = new TourCategory();
		parameters.setName(HtmlUtils.htmlEscape(tourCategory));
		tourCategoryDao.insert(parameters);
	}

	public List<TourCategory> query() {
		return tourCategoryDao.query(new TourCategory());
	}

	public List<String> queryCategory() {
		List<TourCategory> tourCategorieList = query();
		List<String> categoryList = new ArrayList<String>();
		for(TourCategory tourCategory : tourCategorieList) {
			categoryList.add(tourCategory.getName());
		}
		return categoryList;
	}

	public void setTourCategoryDao(TourCategoryDao tourCategoryDao) {
		this.tourCategoryDao = tourCategoryDao;
	}

}
